import axios from 'axios';
import config from "@/util/config.js";

const API_URL = config.wmUrl+'/wm/ware/area';

const wareAreaAPI = {
    //添加
    addWareArea(param, callback) {
        axios.post(API_URL + '/add', param).then(res => {
            callback(res.data);
        });
    },
    //删除
    deleteWareArea(param, callback) {
        axios.delete(API_URL + '/del?wareAreaId=' + param.wareAreaId).then(res => {
            callback(res.data);
        });
    },
    //修改
    updateWareArea(param, callback) {
        axios.request({
            url: `${API_URL}/update`,
            method: 'put',
            data: JSON.stringify(param),
            headers: {
                "Content-Type": "application/json;charset=UTF-8"
            }
        }).then((res)=>{
            callback(res.data);
        })
    },
    //查询
    getWareArea(param, callback) {
        axios.get(`${API_URL}/query?wareId=${param.wareId}&wareAreaName=${param.wareAreaName}&page=${param.page}&limit=${param.limit}`).then(res => {
            callback(res.data);
        });
    },
    //获取数量
    getWareAreaCount(param, callback) {
        axios.get(`${API_URL}/count?wareId=${param.wareId}`).then(res => {
            callback(res.data);
        });
    },
};
export default wareAreaAPI;